function getid(o) { return (typeof o == "object") ? o : document.getElementById(o); }
function getNames(obj, name, tij) {
	var plist = getid(obj).getElementsByTagName(tij);
	var rlist = new Array();
	for (i = 0; i < plist.length; ++i) {
		if (plist[i].getAttribute("name") == name) {
			rlist[rlist.length] = plist[i];
		}
	}
	return rlist;
}
function fiterplay(obj, num, t, name, c1, c2) {
	var fitlist = getNames(obj, name, t);
	for (i = 0; i < fitlist.length; ++i) {
		if (i == num) {
			fitlist[i].className = c1;
		}
		else {
			fitlist[i].className = c2;
		}
	}
}
function play(obj, num,isClick) {
	var s = getid('simg');
	var i = getid('info');
	var b = getid('bimg');
	if (isClick) {
		n = num;
		clearAuto();
		autoStart = 0;
	}
	try {
		with (b) {
			filters[0].Apply();
			fiterplay(b, num, "div", "f", "dis", "undis");
			fiterplay(s, num, "div", "f", "", "f1");
			fiterplay(i, num, "div", "f", "dis", "undis");
			filters[0].play();
		}
	}
	catch (e) {
		fiterplay(b, num, "div", "f", "dis", "undis");
		fiterplay(s, num, "div", "f", "", "f1");
		fiterplay(i, num, "div", "f", "dis", "undis");
	}
}
function divMouseOut() {
	setAuto();
}
function mouseOnImage() {
	clearAuto();
}
function mouseOutImage() {
	setAuto();
}
function clearAuto() {
	clearInterval(autoStart);
	autoStart = 0;
};
function setAuto() {
	if(autoStart==0)
		autoStart = setInterval("auto(n)", 3000)
}
function auto() {
	n++;
	if (n > (x.length - 1)) {
		n = 0;
		//clearAuto();
	}
	play(x[n], n);

}

var autoStart = 0;
var n = 0; 
var s;
var x;

function rotator() {
	setAuto();

}

$(document).ready(function() {
	s = getid("simg");
	x = getNames(s, "f", "div");
	rotator();
});
